﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using HustQQInterface;
using HustQQModel;

namespace HustQQClient.UI
{
    public partial class Register : Form
    {
        public Register()
        {
            InitializeComponent();
            picFace.Image = InfoControl.FaceList[0];
            InfoControl.CurrentUser.face = 0;
        }


        private void btnRegister_Click(object sender, EventArgs e)
        {

            InfoControl.CurrentUser.name = textName.Text;
            InfoControl.CurrentUser.password = textPw1.Text;
            InfoControl.CurrentUser.age = int.Parse(textAge.Text);
            InfoControl.CurrentUser.sex = radioMale.Checked ? 0 : 1;
            InfoControl.CurrentUser.birthday = datePickerBirth.Text;
            InfoControl.CurrentUser.telephone = textPhone.Text;
            InfoControl.CurrentUser.address = textAddr.Text;
            InfoControl.CurrentUser.qq_ID=InterfaceManager.NetManager.Register(InfoControl.CurrentUser);
            this.Hide();
            MessageBox.Show("您获得HQ号：" + InfoControl.CurrentUser.qq_ID);
        }

        private void textPw1_KeyUp(object sender, KeyEventArgs e)
        {
            if (textPw1.Text == textPw2.Text && textPw1.Text != "")
            {
                picJudge.Image = imageList.Images[0];
            }
            else
            {
                picJudge.Image = imageList.Images[1];
            }
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void linkFace_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            InfoControl.CurrentUser.face=new Random(DateTime.Now.Millisecond).Next(40);
            picFace.Image = InfoControl.FaceList[InfoControl.CurrentUser.face];
        }

    }
}
